package com.google.zahra.soap;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.apache.commons.codec.binary.Base64;

public class MD5Hash {
	public MD5Hash(final String data) {
		SetUp();
		md.update(data.getBytes(), 0, data.length());
	}

	public MD5Hash(final String[] data) {
		SetUp();
		for (String i : data) {
			md.update(i.getBytes(), 0, i.length());
		}
	}

	public final String getHash() {
		return Base64.encodeBase64URLSafeString(md.digest());
	}

	private void SetUp() {
		try {
			md = MessageDigest.getInstance("MD5");
		} catch (NoSuchAlgorithmException e) {
		}
	}

	private MessageDigest md = null;
}
